# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
 
@File:trypinyin02.py
@Time:2022/2/22 8:28

@Motto:不积跬步无以至千里，不积小流无以成江海！
"""
import pypinyin
from pypinyin import lazy_pinyin,pinyin



#print(pinyin('规上服务业'))

#print(lazy_pinyin('规上服务业'))

#print(lazy_pinyin('规上服务业',3))


#result_=lazy_pinyin('规上服务业',3)

#字符串转拼音仅声母
def hans2py(str):
    result1=lazy_pinyin(str)
    #print(f'result1结果是:{result1}')
    result_=[i[0] for i in result1]
    #print(f'result_结果是:{result_}')
    #print(result_)
    result3=result_[0].capitalize()+''.join(result_[1:]).capitalize()
    #print(result3)
    return result3

#字符串转拼音全,pypinyin.NORMAL不加音调
def hans2pyq(str):
    result1=pinyin(str,style=pypinyin.NORMAL)
    #print(f'result1结果是:{result1}')
    result_=[i[0] for i in result1]
    #print(f'result_结果是:{result_}')
    result3=result_[0].capitalize()+''.join(result_[1:]).capitalize()
    #print(result3)
    return result3

print(hans2py('规上服务业'))
print(hans2py('规上服务业678'))
print(hans2pyq("规上服务业"))
print(hans2pyq("规上服务业567"))